package com.dingpeikeji.quickdeer.modules.officeup.entity;

import java.util.List;

import org.hibernate.validator.constraints.Length;

import com.dingpeikeji.quickdeer.core.common.persistence.DataEntity;
import com.dingpeikeji.quickdeer.core.modules.sys.entity.Office;
import com.google.common.collect.Lists;

/**
 * 普通客户升级Entity
 * @author dingpei
 * @version 2016-12-08
 */
public class TOfficeUp extends DataEntity<TOfficeUp> {
	
	private static final long serialVersionUID = 1L;
	private Integer upid;		// 主键
	private Office office;		// office_id
	private String isdiscount;		// isdiscount
	private String issche;		// issche
	private String contacts;		// 旅行商：财务联系人
	private String contactstel;		// 旅行商：财务联系人手机
	private String usetype;			// 用车类型
	private String userate;			// 用车频率
	private String companyname;		// 公司名称
	private String address;			// 经营地址
	private String auditstatus;		// 审核状态
	
	private List<OfficeUpUsetype> usetypeList = Lists.newArrayList();
	private List<OfficeUpUserate> userateList = Lists.newArrayList();
	
	public TOfficeUp() {
		usetypeList.add(new OfficeUpUsetype("按天", "1"));
		usetypeList.add(new OfficeUpUsetype("旅游", "2"));
		usetypeList.add(new OfficeUpUsetype("接送", "3"));
		usetypeList.add(new OfficeUpUsetype("旅行", "4"));
		
		userateList.add(new OfficeUpUserate("1周1-2次", "1"));
		userateList.add(new OfficeUpUserate("1周3-5次", "2"));
		userateList.add(new OfficeUpUserate("一周五次以上", "3"));
	}
	
	public class OfficeUpUserate {
		private String name; // 名称
		private String value; // 值
		private String checked; // 为“checked”则为选中
		
		public OfficeUpUserate(String name,String value) {
			this.name = name;
			this.value = value;
		}	
		
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		public String getValue() {
			return value;
		}
		public void setValue(String value) {
			this.value = value;
		}
		public String getChecked() {
			return checked;
		}
		public void setChecked(String checked) {
			this.checked = checked;
		}
	}
	
	public class OfficeUpUsetype {
		private String name; // 名称
		private String value; // 值
		private String checked; // 为“checked”则为选中
		
		public OfficeUpUsetype(String name,String value) {
			this.name = name;
			this.value = value;
		}
		
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		public String getValue() {
			return value;
		}
		public void setValue(String value) {
			this.value = value;
		}
		public String getChecked() {
			return checked;
		}
		public void setChecked(String checked) {
			this.checked = checked;
		}
	}
	
	public Integer getUpid() {
		return upid;
	}

	public void setUpid(Integer upid) {
		this.upid = upid;
	}
	
	public Office getOffice() {
		return office;
	}

	public void setOffice(Office office) {
		this.office = office;
	}
	
	@Length(min=1, max=1, message="是否申请成为整车优惠客户长度必须介于 1 和 1 之间")
	public String getIsdiscount() {
		return isdiscount;
	}

	public void setIsdiscount(String isdiscount) {
		this.isdiscount = isdiscount;
	}
	
	@Length(min=1, max=1, message="是否申请可以发布班次车长度必须介于 1 和 1 之间")
	public String getIssche() {
		return issche;
	}

	public void setIssche(String issche) {
		this.issche = issche;
	}
	
	@Length(min=0, max=30, message="财务联系人长度必须介于 0 和 30 之间")
	public String getContacts() {
		return contacts;
	}

	public void setContacts(String contacts) {
		this.contacts = contacts;
	}
	
	@Length(min=0, max=20, message="财务联系人手机长度必须介于 0 和 20 之间")
	public String getContactstel() {
		return contactstel;
	}

	public void setContactstel(String contactstel) {
		this.contactstel = contactstel;
	}

	public String getUsetype() {
		return usetype;
	}

	public void setUsetype(String usetype) {
		this.usetype = usetype;
		// 初始化选中
		if(this.usetype!=null && !this.usetype.equals("")) {
			String arr[] = usetype.split(",");
			for(String item : arr) {
				for(OfficeUpUsetype ouu : this.usetypeList) {
					if(ouu.getValue().equals(item)) {
						ouu.setChecked("checked");
					}
				}
			}
		}
	}

	public String getUserate() {
		return userate;
	}

	public void setUserate(String userate) {
		this.userate = userate;
		// 初始化选中
		if(this.userate!=null && !this.userate.equals("")) {
			String arr[] = userate.split(",");
			for(String item : arr) {
				for(OfficeUpUserate ouu : this.userateList) {
					if(ouu.getValue().equals(item)) {
						ouu.setChecked("checked");
					}
				}
			}
		}
	}

	public String getCompanyname() {
		return companyname;
	}

	public void setCompanyname(String companyname) {
		this.companyname = companyname;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public List<OfficeUpUsetype> getUsetypeList() {
		return usetypeList;
	}

	public void setUsetypeList(List<OfficeUpUsetype> usetypeList) {
		this.usetypeList = usetypeList;
	}

	public List<OfficeUpUserate> getUserateList() {
		return userateList;
	}

	public void setUserateList(List<OfficeUpUserate> userateList) {
		this.userateList = userateList;
	}

	public String getAuditstatus() {
		return auditstatus;
	}

	public void setAuditstatus(String auditstatus) {
		this.auditstatus = auditstatus;
	}
	
}